<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>Title</title>
    <link rel="stylesheet" href="../static/plugins/layui/css/layui.css">
</head>
<style>
    .ok-body {
        padding: 10px
    }
</style>

<body>
<div class="ok-body">

    <blockquote class="layui-elem-quote layui-text">
        巡检指令结果
    </blockquote>

    <form class="layui-form" action="">
        <div class="layui-form-item">
            <input type="hidden" name="id" id="id"  th:value="${id}" >

            <div class="layui-form-item" >
                <div class="layui-input-block" style="margin: auto">
                    <textarea name="result" placeholder="输入巡检结果" lay-verify="required"  class="layui-textarea"></textarea>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="submit">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>

    </form>

</div>

<script src="../static/plugins/layui/layui.js"></script>
<script src="../static/js/jquery-3.2.1.min.js"></script>
<script src="../static/js/jquery.base64.js"></script>
<script src="../static/js/device.js"></script>

<script th:inline="none">
    layui.use(['form'], function(){
        var form = layui.form;
        var id = $('#id').val();

        JJZ.requestData('/inspectionTask/getInspectionTask','id='+id,function(data){
            JJZ.named('result').val(data.result);
        });
        form.on('submit(submit)', function(data){

            var param = 'id='+data.field.id+'&result='+data.field.result;
            JJZ.requestData('/inspectionTask/addResult',param,function (dataInfo) {
                window.location.href = JJZ.baseUrl+'/inspectionTask/inspectionTaskDataGrid';
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

    });
</script>
</body>
</html>